package com.portal.tag;

import javax.portlet.PortletResponse;
import javax.portlet.PortletURL;
import javax.portlet.RenderResponse;
import javax.portlet.ResourceResponse;
import javax.servlet.jsp.JspException;

import com.portal.util.constants.TagConstants;

public class ActionURLTag286 extends PortletURLTag286 {

  private static final long serialVersionUID = 286L;

  private String name = null;

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  @Override
  public int doEndTag() throws JspException {
    if (name != null) {
      addParameter(TagConstants.PORTLET_ACTION, name);
    }
    return super.doEndTag();
  }

  @Override
  protected PortletURL createPortletUrl(PortletResponse portletResponse) {
    if (portletResponse instanceof RenderResponse) {
      return ((RenderResponse) portletResponse).createActionURL();
    } else if (portletResponse instanceof ResourceResponse) {
      return ((ResourceResponse) portletResponse).createActionURL();
    }
    throw new IllegalArgumentException();
  }

}
